unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,Uni,UniConnct,UniConfig,SQLiteUniProvider,SQLServerUniProvider,
  OracleUniProvider,Dialog_View,UniPatchx, UniProvider, ODBCUniProvider,
  AccessUniProvider;

type
  TFormMain = class(TDialogView)
    Btnx_1: TButton;
    procedure Btnx_1Click(Sender: TObject);
  private
    FUniConfig:TUniConfig;
  protected
    procedure SetInitialize;override;
    procedure SetCommParams;override;
    procedure SetGridParams;override;
    procedure SetComboItems;override;
    procedure TryFreeAndNil;override;
  public
    procedure OnUniConnctCustomConnectionEventBySQL(AConnectionMark:string;var SQLA:string);
  end;

var
  FormMain: TFormMain;

implementation

uses
  Dialog_ListUniConfig;

{$R *.dfm}

procedure TFormMain.Btnx_1Click(Sender: TObject);
begin
  if FUniConfig=nil then
  begin
    FUniConfig:=TUniConfig.Create;
  end;

  if ViewListUniConfig(dlucemView,FUniConfig,False)=Mrok then
  begin
    ShowMessage(FUniConfig.DataBase);
  end;
end;

procedure TFormMain.OnUniConnctCustomConnectionEventBySQL(
  AConnectionMark: string; var SQLA: string);
begin
  SQLA:=Format('SELECT * FROM TBL_UNICONFIG WHERE UNIX_MARK=%S',[QuotedStr(AConnectionMark)]);
end;

procedure TFormMain.SetComboItems;
begin
  inherited;

end;

procedure TFormMain.SetCommParams;
begin
  inherited;

end;

procedure TFormMain.SetGridParams;
begin
  inherited;

end;

procedure TFormMain.SetInitialize;
begin
  inherited;
  UniConnctEx.ConnctMark:='DEMO,XTGL,PRMS';
  UniConnctEx.ConnctMode:=cmBySQL;
  UniConnctEx.OnUniConnctCustomConnectionEventBySQL := OnUniConnctCustomConnectionEventBySQL;

  //Exit;
  if not UniConnctEx.ChkConnection('DEMO') then Exit;

  UniPatchxEx.Initialize('DEMO','TBL_YOTO_DICT');
  UniPatchxEx.Execute;
end;

procedure TFormMain.TryFreeAndNil;
begin
  inherited;
  if FUniConfig<>nil then
  begin
    FreeAndNil(Funiconfig);
  end;  
end;

end.
